<?php

$dblink = @mysql_connect("localhost","sm",""); $database = "sm";

if (!$dblink) {
    die('Could not connect: ' . mysql_error());
}
# select and open database
mysql_select_db($database,$dblink);

$DataArray = Array();

$result = mysql_query('SELECT id, name FROM sm_files');
while ($row = mysql_fetch_assoc($result)) {
	$DataArray[ $row["id"] ] = Array( "name" => $row["name"], "funclist" => Array() );
}

$result = mysql_query('SELECT id, name, owner, description FROM sm_natives');
while ($row = mysql_fetch_assoc($result)) {
	$DataArray[ $row["owner"] ]["funclist"][ $row["id"] ] = Array( $row["name"], $row["description"] );
}

echo json_encode( $DataArray );


?>